package com.eflying.category.web.servlet;

import cn.itcast.servlet.BaseServlet;
import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.eflying.category.bean.Category;
import com.eflying.category.service.CategoryService;

/**
 * Servlet implementation class CategoryServlet
 */
@WebServlet("/CategoryServlet")
public class CategoryServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	CategoryService categoryService = new CategoryService();

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	public String findAll(HttpServletRequest request, HttpServletResponse response){
		/*
		 * 1.通过service得到所有的分类
		 */
		List<Category> parents = categoryService.findAll();
		/*
		 * 2.保存到request中,转发回去
		 */
	/*	System.out.println(parents);*/
		request.setAttribute("parents", parents);
		return "f:/jsps/left.jsp";
	}

}
